home *** CD-ROM | disk | FTP | other *** search
/ Merciful 5 / Merciful - Disc 5.iso / software / p / pcqpascalv1.2d.lha / Include / Devices / TrackDisk.i < prev   
Text File  |  1997-05-06  |  9KB  |  252 lines

  1. {
  2.         Trackdisk.i for PCQ Pascal
  3. }
  4.  
  5. {$I "Include:Exec/IO.i"}
  6. {$I "Include:Exec/Devices.i"}
  7.  
  8. {
  9.  *--------------------------------------------------------------------
  10.  *
  11.  * Physical drive constants
  12.  *
  13.  *--------------------------------------------------------------------
  14. }
  15.  
  16. Const
  17.  
  18.     NUMSECS     = 11;
  19.     NUMUNITS    = 4;
  20.  
  21. {
  22.  *--------------------------------------------------------------------
  23.  *
  24.  * Useful constants
  25.  *
  26.  *--------------------------------------------------------------------
  27.  }
  28.  
  29. {-- sizes before mfm encoding }
  30.     TD_SECTOR   = 512;
  31.     TD_SECSHIFT = 9;            { log TD_SECTOR }
  32.  
  33. {
  34.  *--------------------------------------------------------------------
  35.  *
  36.  * Driver Specific Commands
  37.  *
  38.  *--------------------------------------------------------------------
  39.  }
  40.  
  41. {
  42.  *-- TD_NAME is a generic macro to get the name of the driver.  This
  43.  *-- way if the name is ever changed you will pick up the change
  44.  *-- automatically.
  45.  *--
  46.  *-- Normal usage would be:
  47.  *--
  48.  *-- char internalName[] = TD_NAME;
  49.  *--
  50.  }
  51.  
  52.     TD_NAME     = "trackdisk.device";
  53.  
  54.     TDF_EXTCOM  = $00010000;            { for internal use only! }
  55.  
  56.  
  57.     TD_MOTOR            = CMD_NONSTD + 0;       { control the disk's motor }
  58.     TD_SEEK             = CMD_NONSTD + 1;       { explicit seek (for testing) }
  59.     TD_FORMAT           = CMD_NONSTD + 2;       { format disk }
  60.     TD_REMOVE           = CMD_NONSTD + 3;       { notify when disk changes }
  61.     TD_CHANGENUM        = CMD_NONSTD + 4;       { number of disk changes }
  62.     TD_CHANGESTATE      = CMD_NONSTD + 5;       { is there a disk in the drive? }
  63.     TD_PROTSTATUS       = CMD_NONSTD + 6;       { is the disk write protected? }
  64.     TD_RAWREAD          = CMD_NONSTD + 7;       { read raw bits from the disk }
  65.     TD_RAWWRITE         = CMD_NONSTD + 8;       { write raw bits to the disk }
  66.     TD_GETDRIVETYPE     = CMD_NONSTD + 9;       { get the type of the disk drive }
  67.     TD_GETNUMTRACKS     = CMD_NONSTD + 10;      { # of tracks for this type drive }
  68.     TD_ADDCHANGEINT     = CMD_NONSTD + 11;      { TD_REMOVE done right }
  69.     TD_REMCHANGEINT     = CMD_NONSTD + 12;      { remove softint set by ADDCHANGEINT }
  70.     TD_GETGEOMETRY      = CMD_NONSTD + 13;
  71.     TD_EJECT            = CMD_NONSTD + 14;      { for those drives that support it }
  72.     TD_LASTCOMM         = CMD_NONSTD + 15;
  73.  
  74. {
  75.  *
  76.  * The disk driver has an "extended command" facility.  These commands
  77.  * take a superset of the normal IO Request block.
  78.  *
  79.  }
  80.  
  81.     ETD_WRITE           = CMD_WRITE + TDF_EXTCOM;
  82.     ETD_READ            = CMD_READ + TDF_EXTCOM;
  83.     ETD_MOTOR           = TD_MOTOR + TDF_EXTCOM;
  84.     ETD_SEEK            = TD_SEEK + TDF_EXTCOM;
  85.     ETD_FORMAT          = TD_FORMAT + TDF_EXTCOM;
  86.     ETD_UPDATE          = CMD_UPDATE + TDF_EXTCOM;
  87.     ETD_CLEAR           = CMD_CLEAR + TDF_EXTCOM;
  88.     ETD_RAWREAD         = TD_RAWREAD + TDF_EXTCOM;
  89.     ETD_RAWWRITE        = TD_RAWWRITE + TDF_EXTCOM;
  90.  
  91. {
  92.  *
  93.  * extended IO has a larger than normal io request block.
  94.  *
  95.  }
  96.  
  97. Type
  98.  
  99.     IOExtTD = record
  100.         iotd_Req        : IOStdReq;
  101.         iotd_Count      : Integer;
  102.         iotd_SecLabel   : Integer;
  103.     end;
  104.     IOExtTDPtr = ^IOExtTD;
  105.  
  106. {
  107.  *  This is the structure returned by TD_DRIVEGEOMETRY
  108.  *  Note that the layout can be defined three ways:
  109.  *
  110.  *  1. TotalSectors
  111.  *  2. Cylinders and CylSectors
  112.  *  3. Cylinders, Heads, and TrackSectors.
  113.  *
  114.  *  #1 is most accurate, #2 is less so, and #3 is least accurate.  All
  115.  *  are usable, though #2 and #3 may waste some portion of the available
  116.  *  space on some drives.
  117.  }
  118.        DriveGeometry = Record
  119.         dg_SectorSize,          {    in bytes }
  120.         dg_TotalSectors,        {    total # of sectors on drive }
  121.         dg_Cylinders,           {    number of cylinders }
  122.         dg_CylSectors,          {    number of sectors/cylinder }
  123.         dg_Heads,               {    number of surfaces }
  124.         dg_TrackSectors,        {    number of sectors/track }
  125.         dg_BufMemType : Integer;          {    preferred buffer memory type }
  126.                                         {    (usually MEMF_PUBLIC) }
  127.         dg_DeviceType,          {    codes as defined in the SCSI-2 spec}
  128.         dg_Flags      : Byte;               {    flags, including removable }
  129.         dg_Reserved   : Short;
  130.        END;
  131.        DriveGeometryPtr = ^DriveGeometry;
  132.  
  133.  
  134. Const
  135. {    device types }
  136.     DG_DIRECT_ACCESS       = 0 ;
  137.     DG_SEQUENTIAL_ACCESS   = 1 ;
  138.     DG_PRINTER             = 2 ;
  139.     DG_PROCESSOR           = 3 ;
  140.     DG_WORM                = 4 ;
  141.     DG_CDROM               = 5 ;
  142.     DG_SCANNER             = 6 ;
  143.     DG_OPTICAL_DISK        = 7 ;
  144.     DG_MEDIUM_CHANGER      = 8 ;
  145.     DG_COMMUNICATION       = 9 ;
  146.     DG_UNKNOWN             = 31;
  147.  
  148. {    flags }
  149.     DGB_REMOVABLE          = 0;
  150.     DGF_REMOVABLE          = 1;
  151.  
  152. {
  153. ** raw read and write can be synced with the index pulse.  This flag
  154. ** in io request's IO_FLAGS field tells the driver that you want this.
  155. }
  156.  
  157.     IOTDB_INDEXSYNC     = 4;
  158.     IOTDF_INDEXSYNC     = 16;
  159.  
  160. {
  161. ** raw read and write can be synced with a $4489 sync pattern.  This flag
  162. ** in io request's IO_FLAGS field tells the driver that you want this.
  163. }
  164.     IOTDB_WORDSYNC = 5;
  165.     IOTDF_WORDSYNC = 32;
  166.  
  167.  
  168. { labels are TD_LABELSIZE bytes per sector }
  169.  
  170.     TD_LABELSIZE        = 16;
  171.  
  172. {
  173. ** This is a bit in the FLAGS field of OpenDevice.  If it is set, then
  174. ** the driver will allow you to open all the disks that the trackdisk
  175. ** driver understands.  Otherwise only 3.5" disks will succeed.
  176. }
  177.  
  178.     TDB_ALLOW_NON_3_5   = 0;
  179.     TDF_ALLOW_NON_3_5   = 1;
  180.  
  181. {
  182. **  If you set the TDB_ALLOW_NON_3_5 bit in OpenDevice, then you don't
  183. **  know what type of disk you really got.  These defines are for the
  184. **  TD_GETDRIVETYPE command.  In addition, you can find out how many
  185. **  tracks are supported via the TD_GETNUMTRACKS command.
  186. }
  187.  
  188.     DRIVE3_5            = 1;
  189.     DRIVE5_25           = 2;
  190.     DRIVE3_5_150RPM     = 3;
  191.  
  192. {
  193.  *--------------------------------------------------------------------
  194.  *
  195.  * Driver error defines
  196.  *
  197.  *--------------------------------------------------------------------
  198.  }
  199.  
  200.     TDERR_NotSpecified          = 20;   { general catchall }
  201.     TDERR_NoSecHdr              = 21;   { couldn't even find a sector }
  202.     TDERR_BadSecPreamble        = 22;   { sector looked wrong }
  203.     TDERR_BadSecID              = 23;   { ditto }
  204.     TDERR_BadHdrSum             = 24;   { header had incorrect checksum }
  205.     TDERR_BadSecSum             = 25;   { data had incorrect checksum }
  206.     TDERR_TooFewSecs            = 26;   { couldn't find enough sectors }
  207.     TDERR_BadSecHdr             = 27;   { another "sector looked wrong" }
  208.     TDERR_WriteProt             = 28;   { can't write to a protected disk }
  209.     TDERR_DiskChanged           = 29;   { no disk in the drive }
  210.     TDERR_SeekError             = 30;   { couldn't find track 0 }
  211.     TDERR_NoMem                 = 31;   { ran out of memory }
  212.     TDERR_BadUnitNum            = 32;   { asked for a unit > NUMUNITS }
  213.     TDERR_BadDriveType          = 33;   { not a drive that trackdisk groks }
  214.     TDERR_DriveInUse            = 34;   { someone else allocated the drive }
  215.     TDERR_PostReset             = 35;   { user hit reset; awaiting doom }
  216.  
  217. {
  218.  *--------------------------------------------------------------------
  219.  *
  220.  * public portion of the unit structure
  221.  *
  222.  *--------------------------------------------------------------------
  223.  }
  224.  
  225. Type
  226.  
  227.     TDU_PublicUnit = record
  228.         tdu_Unit        : Unit;         { base message port }
  229.         tdu_Comp01Track : Short;        { track for first precomp }
  230.         tdu_Comp10Track : Short;        { track for second precomp }
  231.         tdu_Comp11Track : Short;        { track for third precomp }
  232.         tdu_StepDelay   : Integer;      { time to wait after stepping }
  233.         tdu_SettleDelay : Integer;      { time to wait after seeking }
  234.         tdu_RetryCnt    : Byte;         { # of times to retry }
  235.         tdu_PubFlags    : Byte;         {    public flags, see below }
  236.         tdu_CurrTrk     : Short;        {    track the heads are over... }
  237.                                         {    ONLY ACCESS WHILE UNIT IS STOPPED! }
  238.         tdu_CalibrateDelay : Integer;   {    time to wait after stepping }
  239.                                         {    during a recalibrate }
  240.         tdu_Counter     : Integer;      {    counter for disk changes... }
  241.                                         {    ONLY ACCESS WHILE UNIT IS STOPPED! }
  242.  
  243.     end;
  244.     TDU_PublicUnitPtr = ^TDU_PublicUnit;
  245.  
  246. CONST
  247. {    flags for tdu_PubFlags }
  248.     TDPB_NOCLICK  =  0;
  249.     TDPF_NOCLICK  =  1;
  250.  
  251.  
  252.